<template>
	<view>
		<view class="tabs">
			<u-tabs :list="list1" :scrollable="false" @click="click"></u-tabs>
		</view>
		<navigator :url="'/pages/task/submitDetail?id='+item.id" class="list" v-for="(item,index) in list"
			:key="index">
			<view class="title">任务名称：{{item.task_name}}</view>
			<view class="time">链接：{{item.link}}</view>
			<view class="flex align time between">
				<view></view>
				<view>提交时间：{{item.create_time}}</view>
			</view>
			<view class="status">{{item.check_status==1?'待审核':item.check_status==2?'审核通过':'审核未通过'}}</view>
		</navigator>
		<uni-load-more :status="status" v-if="!empty" :content-text="loadText"></uni-load-more>
		<xw-empty :isShow="empty" text="暂无数据" textColor="#777777"></xw-empty>
	</view>
</template>

<script>
	import {
		taskSubmitLists
	} from '@/api/apiData.js';
	export default {
		data() {
			return {
				list1: [{
					name: '待审核',
				}, {
					name: '审核通过',
				}, {
					name: '审核未通过'
				}],
				totalPage: 1,
				page: 0,
				offset: 10,
				list: [],
				scrollTop: 0,
				empty: false,
				loadText: {
					loadmore: '点击或上拉加载更多',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				status: 'loadmore',
				check_status: 1,
				task_id:''
			};
		},
		onLoad(option) {
			this.task_id = option.id
			this.getlist()
		},
		onPageScroll(e) {
			const that = this;
			that.scrollTop = e.scrollTop;
		},
		onReachBottom() {
			const that = this;
			that.getlist();
		},
		methods: {
			click(item) {
				console.log('item', item);
				this.check_status = item.index + 1
				this.page = 0
				this.list = []
				this.getlist();
			},
			async getlist() {
				const that = this;
				const {
					totalPage,
					page,
					offset,
					list,
					check_status,
					task_id
				} = that;
				let obj = {
					size: offset,
					page: page + 1,
					check_status,
					task_id
				};
				that.status = 'loading';
				if (totalPage > page) {
					let result = await taskSubmitLists(obj);
					if (result.code == 1) {
						that.page = page + 1;
						if (result.data.total == 0) {
							console.log((888))
							that.empty = true;
							that.status = 'nomore';
							return;
						}
						that.empty = false;
						setTimeout(() => {
							that.status = 'loadmore';
						}, 500);
						that.list = list.concat(result.data.list);
						that.totalPage = Math.ceil(result.data.total / offset);
					}
				} else {
					setTimeout(() => {
						that.status = 'nomore';
					}, 500);
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.tabs {
		background: white;
	}

	.list {
		background: white;
		margin: 32rpx;
		padding: 24rpx;
		border-radius: 8rpx;
		position: relative;

		.title {
			color: #333333;
			font-size: 30rpx;
			font-weight: bold;
			margin-bottom: 20rpx;
		}

		.time {
			color: #666666;
			font-size: 24rpx;
			margin-top: 18rpx;
		}

		.status {
			color: #FF8900;
			border: solid 1rpx;
			font-size: 20rpx;
			position: absolute;
			top: 24rpx;
			right: 24rpx;
			padding: 6rpx 18rpx;
			border-radius: 4rpx;
		}
	}
</style>